package com.cn.yang.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.yang.bean.DianDao;
import com.cn.yang.service.DianDaoService;
import com.cn.yang.util.SortUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dianDao")
public class DianDaoController {
    @Autowired
    DianDaoService dianDaoService;

    @RequestMapping("/dianDaoAdd")
    public JSONObject dianDaoAdd(@RequestBody List<DianDao> list) {
        int result = dianDaoService.dianDaoAdd(list);
        if (result>0){
            result = 1;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",result);
        return jsonObject;
    }
    @RequestMapping("/dianDaoState")
    public JSONObject dianDaoState() {
        List<DianDao> list = dianDaoService.dianDaoState();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        return jsonObject;
    }
    @RequestMapping("/selectAllData")
    public JSONObject selectAllData(@RequestBody DianDao dianDao) {
        List<DianDao> list = dianDaoService.selectAllData(dianDao);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        return jsonObject;
    }
    @RequestMapping("/selectToday")
    public JSONObject selectToday(@RequestBody DianDao dianDao) {
        int result = dianDaoService.selectToday(dianDao);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",result);
        return jsonObject;
    }
}
